﻿using AMatysiak.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AMatysiak.Methods;

namespace AMatysiakTest
{
    [TestClass]
    public class ObjectBoxTest
    {
        [TestMethod]
        public void testIntTextBox()
        {
            ObjectBox box = new ObjectBox();
            box.Text = "10";

            Assert.AreEqual("10", box.Value);
        }

        [TestMethod]
        public void testSetValue()
        {
            ObjectBox box = new ObjectBox();
            box.Value = 10.25;

            Assert.AreEqual("10,25", box.Text);
        }

        [TestMethod]
        public void testChangeMethodToString()
        {
            ObjectBox box = new ObjectBox();
            box.FormatMethodToStrHandler = delegate(object value) { return double.Parse(value.ToString()).ToString("C2"); };
            box.Value = 11;

            Assert.AreEqual("11,00 zł", box.Text);
        }

        [TestMethod]
        public void testChangeMethodToObject()
        {
            ObjectBox box = new ObjectBox();
            box.FormatMethodToObjHandler = delegate(string value) { return value.ToString().ToDouble(); };
            box.Text = "11,00 zł";

            Assert.AreEqual(11d, box.Value);
        }
    }
}
